s = input()
a = s.split()
k = ""
f = 0
for e in a:
    if e == "one":
        k += "1"
    elif e == "two":
        k += "2"
    elif e == "three":
        k += "3"
    elif e == "four":
        k += "4"
    elif e == "five":
        k += "5"
    elif e == "six":
        k += "6"
    elif e == "seven":
        k += "7"
    elif e == "eight":
        k += "8"
    elif e == "nine":
        k += "9"
    elif e == "zero":
        k += "0"
    else:
        print("Wrong input")
        f = 1
        break
if f == 0:
    n = int(k)
    t = n + 1
    sp = []
    sp1 = []
    for i in range(2, n):
        for j in range(2, i):
            if i % j == 0:
                sp.append(j)
        if len(sp) > 0:
            sp = []
            continue
        else:
            sp1.append(i)
            continue
    x = []
    h = []
    while len(h) == 0:
        for j in range(2, t):
            if t % j == 0:
                x.append(j)
        if len(x) > 0:
            x = []
            t += 1
            continue
        else:
            h.append(t)
            break
    if n - sp1[-1] > h[0] - n:
        print(h[0])
    else:
        print(sp1[-1])